<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>选项配置详情</title>
    <!-- 引入 Element UI 的样式 -->
    <link rel="stylesheet" href="../../assets/css/element-ui.css" />
    <link rel="stylesheet" href="../../assets/css/styles.css" />
    <script src="../../assets/js/cdn.js"></script>
    <link rel="stylesheet" href="../../assets/fontawesome-free-6.7.2-web/css/all.min.css" />
  </head>
  <body>
    <div id="app">
      <!-- <div class="header">
        <div class="container header-content">
          <div class="logo">订单管理系统</div>
          <div style="position: absolute; left: 50%;">
            <el-button type="primary" size="large" @click="openMenu('../../index.html')">
              首页
            </el-button>
            <el-dropdown size="large" @command="openMenu">
              <el-button type="primary" size="large">
                业务中心<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item v-for="item in businessCenters" :command="item.path">{{item.name}}</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <div class="user-info" v-if="currentUser.name">
            欢迎，{{ currentUser.name }}
            <el-button type="primary" size="mini" @click="exit(2)">登出</el-button>
          </div>
        </div>
      </div> -->
      <lx-header slot="header" v-on:toggle="isToggle = !isToggle"></lx-header>
      <div class=" main-content">
        <div class="content" style="width: 100%">

          <h1 class="module-title">基本信息</h1>
          <div class="center-grid mb-20">
            <el-descriptions :column="1">
              <el-descriptions-item v-for="item in baseInfoHeader" :key="item.fieldApi" :label="item.label">
                <template v-if="item.fieldApi==='smallConfigCode'">
                    <div>{{ formInfo.smallConfigCode}}-{{getOptionsStr(formInfo.smallConfigCode)}}</div>
                </template>
                <template v-else-if="item.fieldApi==='optionName'">
                  <div>{{ formInfo.optionCode}}-{{formInfo.optionName}}</div>
                </template>
                <template v-else>
                    <div>{{ formInfo[item.fieldApi] ? formInfo[item.fieldApi]:'-' }}</div>
                </template>
              </el-descriptions-item>
            </el-descriptions>
          </div>
        </div>
      </div>
    </div>
    <script src="../../assets/js/constant.js"></script>
    <script src="../../assets/js/utils.js"></script>
    <script src="../../assets/js/auth.js"></script>
    <script src="../../assets/js/axios.min.js"></script>
    <!-- 引入 Vue.js -->
    <script src="../../assets/js/vue.js"></script>
    <!-- 引入 Element UI 的 JS 文件 -->
    <script src="../../assets/js/element-ui.js"></script>

    <script type="module">
      import LxHeader from '../../pages/components/LxHeader/index.js'
      Vue.component('lx-header', LxHeader)
      checkAuthentication(2)
      new Vue({
        el: '#app',
        components: {},
        data() {
         return {
            currentUser: JSON.parse(localStorage.getItem('currentUser')) || {},
            userMenuList: JSON.parse(localStorage.getItem('userMenuList')) || [],
            businessCenters: [
                { name: '订单中心', path: '../index.html' },
                { name: '用户中心', path: '#' },
                { name: '产品中心', path: '#' },
                { name: '库存中心', path: '#' },
                { name: '财务中心', path: '#' },
                { name: '数据中心', path: '#' },
                { name: '系统中心', path: '#' },
                { name: '消息中心', path: '#' }
            ],
            baseInfoHeader: [
              { label: '小类名称', fieldApi: 'smallConfigCode' },
              { label: '选项配置名称', fieldApi: 'optionName' }
            ],
            optionsObj: [],
            formInfo: {},
            detailDialog: false, // 详情
            carModelCode: '',
            root_host: root_host,
            request_host: request_host
          }
        },
        created() {
            this.getSmallConfigList()
            this.init()
        },
        methods: {
          exit,
          init() {
            this.optionCode = getUrlParameter('optionCode')
            this.getDetails()
          },
          getSmallConfigList() {
              axios.get(`${this.request_host}/system/smallConfig/allList`).then((response) => {
                  if (response.status == 200) {
                      this.optionsObj = response.data.data
                  }
              })
          },
          getDetails() {
            // 这里替换为实际的API调用
            axios.get(`${this.request_host}/system/smallConfigOptions/` + this.optionCode)
                .then(response => {
                    this.formInfo = response.data.data
                });
          },
          getOptionsStr(value) {
            for (const element of this.optionsObj) {
                if(element.smallConfigCode == value){
                    return element.smallConfigName
                }
            }
            return ''
          },
          openMenu(url) {
            window.open(url)
          },
        }
      })
    </script>
    <style>
      .el-table th.el-table__cell {
        background-color: #f2f2f2; /* 例如，设置为浅灰色 */
      }
    </style>
  </body>
</html>
